Skip to content

Conversation

martijnrusschen
Copy link
Member

@martijnrusschen martijnrusschen commented Aug 15, 2025

Summary

• Updated @floating-ui/react from 0.27.12 to 0.27.15 to resolve React 19 compatibility issues
• Fixed TypeScript errors in floating UI integration
• Resolved "Invalid hook call" errors in development environment

Changes Made

Core Library Updates

  • @floating-ui/react: 0.27.12 → 0.27.15 (includes React 19 compatibility fixes for useMergeRefs hook)
  • Updated both main package and docs-site dependencies

Code Fixes

  • src/with_floating.tsx: Fixed useRef(null) typing issue that was causing TypeScript compilation errors
  • Improved component structure with proper displayName for debugging

Development Environment

  • docs-site/vite.config.js: Added React aliases to ensure single React instance and prevent "Invalid hook call" errors during development

Problem Solved

The main issue was React 19's new ref callback cleanup function feature wasn't supported by @floating-ui/react 0.27.12. This caused:

  • "Invalid hook call" errors in development
  • TypeScript compilation failures
  • Multiple React instance conflicts in the docs site

Testing

  • ✅ TypeScript compilation passes (yarn type-check)
  • ✅ Development server runs without "Invalid hook call" errors
  • ✅ Floating UI functionality works correctly with React 19
  • ✅ Docs site builds and runs properly

Technical Details

The @floating-ui/react 0.27.15 update includes fixes for React 19's useMergeRefs hook compatibility, specifically addressing the new cleanup function support for ref callbacks.
The vite.config.js changes ensure consistent React resolution during development to prevent the common "multiple React instances" issue.

Copy link

codecov bot commented Aug 15, 2025

Codecov Report

❌ Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.19%. Comparing base (dcb0028) to head (e9f6002).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
src/popper_component.tsx 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5787      +/-   ##
==========================================
- Coverage   97.20%   97.19%   -0.01%     
==========================================
  Files          30       30              
  Lines        3393     3391       -2     
  Branches     1436     1421      -15     
==========================================
- Hits         3298     3296       -2     
  Misses         95       95              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@martijnrusschen martijnrusschen changed the title Try fixing docs site Fix React 19 compatibility issues with @floating-ui/react Aug 15, 2025
@martijnrusschen
Copy link
Member Author

@balajis-qb can you review?

@martijnrusschen
Copy link
Member Author

@claude Review this PR

Copy link
Contributor

claude bot commented Aug 15, 2025

Claude finished @martijnrusschen's task —— View job


PR Review: React 19 Compatibility Fix

Todo List

  • Read and analyze changed files
  • Review dependency updates
  • Check TypeScript fixes
  • Review configuration changes
  • Provide comprehensive feedback

✅ Overall Assessment

This is a solid fix for React 19 compatibility issues. The changes are focused, well-reasoned, and address the core problems described in the PR.

🔍 Detailed Review

Dependency Updates

package.json: Updated @floating-ui/react from ^0.27.3 to ^0.27.15

  • Good: Significant version jump with important React 19 compatibility fixes
  • Note: The PR description mentions updating from 0.27.12, but git diff shows from 0.27.3 - likely the version was already partially updated

TypeScript Fixes

src/with_floating.tsx:51: Fixed ref typing

- const arrowRef: React.RefObject<HTMLElement | null> = useRef(null);
+ const arrowRef = useRef<SVGSVGElement>(null);
  • Excellent: More specific typing for SVG arrow elements
  • Good: Addresses the TypeScript compilation errors mentioned in the PR

Additional improvements in with_floating.tsx:

  • Added proper displayName for better debugging (line 74)
  • Changed from arrow function to function declaration for better stack traces

Component Modernization

src/popper_component.tsx: Class → Functional Component conversion

  • Good: Converted from class component to functional component
  • Performance: Eliminates class overhead
  • Maintainability: More modern React patterns
  • Compatibility: Better alignment with React 19's direction

Development Environment Fix

docs-site/vite.config.js: Added React aliases

alias: {
  // Ensure single React instance to avoid "Invalid hook call" errors
  react: path.resolve(__dirname, "node_modules/react"),
  "react-dom": path.resolve(__dirname, "node_modules/react-dom"),
}
  • Excellent: Prevents multiple React instances during development
  • Good: Clear comment explaining the purpose

🤔 Coverage Note

Codecov shows 1 missing line in src/popper_component.tsx. This is likely due to:

  • The class → functional component conversion changing code paths
  • The missing coverage appears to be on a conditional branch that may be harder to test

📝 Minor Suggestions

  1. Testing: Consider adding specific tests for React 19 compatibility if not already covered
  2. Documentation: The changes are well-documented in the PR description

✨ What I Like

  • Targeted fixes: Each change addresses a specific React 19 issue
  • Type safety: Improved TypeScript definitions
  • Code quality: Modernization from class to functional components
  • Clear intent: Good comments and commit messages

🎯 Conclusion

Status: Ready to merge

This PR successfully resolves React 19 compatibility issues with focused, high-quality changes. The dependency update, TypeScript fixes, and development environment improvements all work together to solve the "Invalid hook call" errors while modernizing the codebase.


@martijnrusschen martijnrusschen merged commit 6d64eff into main Aug 15, 2025
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant